﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TreeDataStructure
{
    class Tree//<Node> where Node: IComparable<Node>
    {
        public int globalID; //{ get; set; }
        public int localID ;//{ get; set; }
        public int nodeData;//{ get; set; }
        public Tree leftLeaf;// { get; set; }
        public Tree rightLeaf; //{ get; set; }

        //constructor
        public Tree(int globalID, int initialID,int newItem)
        {
            this.localID = initialID;
            this.globalID = globalID;
            this.nodeData = newItem;
            this.leftLeaf = null;
            this.rightLeaf = null;
        }

        //spliting method
        public void spliter(Tree parentNode)
        {           
           parentNode = new Tree(parentNode.globalID, parentNode.localID + 1, parentNode.nodeData);
        }

        //report Method
        public void Report(Tree refrenceNode)
        {
            if (refrenceNode.nodeData == null)
            {
                Console.WriteLine("Leaf: No" + " " + "Node Id: " + refrenceNode.localID);
            }
            else
            {
                Console.WriteLine("Leaf: Yes" + " " + "Node Id: " + refrenceNode.localID);
            }
        }
        
        public void newNode(int globlaID, int localID, Tree parentNode)
        {
            if (parentNode != null)
            {
                Tree childNode = new Tree(parentNode.globalID + 1, 0, parentNode.nodeData);
                childNode.leftLeaf = null;
                childNode.rightLeaf = null;
            }
        }
    }
}
